import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('../views/Home.vue'),
    meta: { title: '首页', keepAlive: false }
  },
  {
    path: '/package',
    name: 'Package',
    component: () => import('../views/Package.vue'),
    meta: { title: '贷款额度', keepAlive: false }
  },
  {
    path: '/credential',
    name: 'Credential',
    component: () => import('../views/Credential.vue'),
    meta: { title: '拍照上传', keepAlive: false }
  },
  {
    path: '/form',
    name: 'Form',
    component: () => import('../views/Form.vue'),
    meta: { title: '信息确认', keepAlive: false }
  },
  {
    path: '/face',
    name: 'Face',
    component: () => import('../views/Face.vue'),
    meta: { title: '人脸识别', keepAlive: false }
  },
  {
    path: '/license',
    name: 'License',
    component: () => import('../views/License.vue'),
    meta: { title: '签署协议', keepAlive: false }
  },
  {
    path: '/match',
    name: 'Match',
    component: () => import('../views/Match.vue'),
    meta: { title: '申请结果', keepAlive: false }
  },
  {
    path: '/result',
    name: 'Result',
    component: () => import('../views/Result.vue'),
    meta: { title: '申请结果', keepAlive: false }
  },
  {
    path: '/promote',
    name: 'Promote',
    component: () => import('../views/Promote.vue'),
    meta: { title: '额度提升', keepAlive: false }
  },
  {
    path: '/tax',
    name: 'tax',
    component: () => import('../views/Tax.vue'),
    meta: { title: '国税授权', keepAlive: false }
  }
]

const router = new VueRouter({
  routes,
  scrollBehavior: () => ({ y: 0 })
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title
  next()
})

export default router
